package restaurant;

/**
 * The Command object to update a menu item.
 * 
 * @author Odessa
 */

public class cmdUpdateMenuItem implements Command
{

	/** The information aggregator. */
	private InformationAggregator info;

	/** The item number of the item being updated. */
	private int itemNo;

	/** The new name of the item. */
	private String name;

	/** The new description of the item. */
	private String description;

	/** The new price of the item. */
	private double price;

	/** The new preparation time of the item. */
	private int prepTime;

	/** The new course of the item. */
	private String course;

	/** Whether or not the updated item is vegetarian. */
	private boolean vegetarian;



	/**
	 * Instantiates a new update menu item command.
	 *
	 * @param info the information aggregator.
	 * @param itemNo the item number of the item to update.
	 * @param name the new name of the item.
	 * @param description the new description of the item.
	 * @param price the new price of the item.
	 * @param prepTime the new preparation time of the item.
	 * @param course the new course of the item.
	 * @param vegetarian whether or not the item is vegetarian.
	 */
	public cmdUpdateMenuItem(InformationAggregator info, int itemNo, String name, String description,
			double price, int prepTime, String course, boolean vegetarian) {
		this.info = info;
		this.itemNo = itemNo;
		this.name = name;
		this.description = description;
		this.price = price;
		this.prepTime = prepTime;
		this.course = course;
		this.vegetarian = vegetarian;
	}



	/**
	 * Updates a menu item.
	 *
	 * @return the updated menu item. 
	 * @see restaurant.Command#execute()
	 */
	@Override
	public Object execute()
	{
		Menu menu = info.getMenu();
		MenuItem updatedItem = menu.updateItem(itemNo, name, description, price, prepTime, course, vegetarian);
		
		return updatedItem;
	}

}
